﻿using Prism.Commands;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace delete.ViewModels
{
    public class CloseDialogViewModel : IDialogAware
    {
        public string Title => "";

        public event Action<IDialogResult> RequestClose;
        //确定命令
        private DelegateCommand _confirmCommand;
        public DelegateCommand ConfirmCommand =>
            _confirmCommand ?? (_confirmCommand = new DelegateCommand(ExecuteConfirmCommand));
        //取消命令
        private DelegateCommand _cancel;
        public DelegateCommand CancelCommand =>
            _cancel ?? (_cancel = new DelegateCommand(ExecuteCancelCommand));

        void ExecuteConfirmCommand()
        {
            RequestClose.Invoke(new DialogResult(ButtonResult.OK)); 
        }

        void ExecuteCancelCommand()
        {
            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
        }
        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
        }
    }
}
